package com.ytjj.qmyx.users.client;

import com.ytjj.common.api.CommonResult;
import com.ytjj.common.model.MyIncomeDataResponse;
import com.ytjj.common.model.MyWalletResponse;
import com.ytjj.common.model.UsersResponse;
import com.ytjj.qmyx.users.model.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;

@FeignClient("ygyx-users")
public interface UsersClient {


    @GetMapping("/users/getUsersInfo")
    UsersDto getUsersInfo(@RequestParam("userId") Integer userId);

    @GetMapping("/users/queryQualityUser")
    List<UsersDto> queryQualityUser(@RequestParam("pageNum")Integer pageNum,
                                    @RequestParam("pageSize") Integer pageSize,
                                    @RequestParam("type") String type);

    @GetMapping("/users/queryNotFollowUser")
    List<UsersDto> queryNotFollowUser(@RequestParam("pageNum")Integer pageNum,
                                      @RequestParam("pageSize") Integer pageSize,
                                      @RequestParam("userId") Integer userId);

    @GetMapping("/users/queryNotFollowUserV2")
    List<UsersDto> queryNotFollowUser(@RequestParam("pageNum")Integer pageNum,
                                      @RequestParam("pageSize") Integer pageSize);

//    @GetMapping("/users/updateMoney")
//    void updateMoney(@RequestParam("userId") Integer userId,@RequestParam("receiveMoney") BigDecimal receiveMoney);

    /**
     * 插入领取红包记录
     * @param userId
     * @param receiveMoney
     */
    @PostMapping("/users/insetUsersBalanceRecord")
    void insetUsersBalanceRecord(@RequestParam("userId")Integer userId, @RequestParam("receiveMoney")BigDecimal receiveMoney);


    @GetMapping("/users/getUser")
    UsersResponse getUsers(@RequestParam("useId") Integer userId);

    @GetMapping("/users/queryCardByUserId")
    List<UsersCardDto> queryCardByUserId(@RequestParam("userId") Integer userId);

    @GetMapping("/users/isSign")
    Integer isSign(@RequestParam("userId") Integer userId);

    @GetMapping("/users/getUsersExpertList")
    List<UsersExpertDto> getUsersExpertList(@RequestParam("type") String type);

    /**
     * 获取优惠券列表
     * @return
     */
    @GetMapping("/users/getUsersCoupontList")
    List<UsersCouponDto> getUsersCoupontList();

    /**
     * 查看该用户是否有优惠券
     * @param userId
     * @param couponId
     */
    @GetMapping("/users/getHaveCoupon")
    List<CouponRelationDto> getHaveCoupon(@RequestParam("userId")Integer userId, @RequestParam("couponId")Integer couponId);

    /**
     * 改变优惠券状态
     * @param id
     */
    @PostMapping("/users/updateUseFlag")
    void updateUseFlag(@RequestParam("id")Integer id);

    /**
     * 获取该用户优惠券列表 new
     * @return
     */
    @GetMapping("/users/getUsersCoupontRelationList")
    List<UsersCouponRelationDto> getUsersCoupontRelationList(@RequestParam("usersId") Integer usersId);

    /**
     * 获取该用户优惠券列表 new
     * @return
     */
    @GetMapping("/users/getUsersCoupontRelationListH5")
    List<UsersCouponRelationDto> getUsersCoupontRelationList();

    /**
     * 根据id获取优惠券
     * @return
     */
    @GetMapping("/users/getUsersCouponById")
    UsersCouponDto getUsersCouponById(@RequestParam("couponId") Integer couponId);

    /**
     * 领取优惠券
     * @param userId
     * @param couponId
     */
    @PostMapping("/users/receiveCoupon")
    void receiveCoupon(@RequestParam("userId")Integer userId, @RequestParam("couponId")Integer couponId);

    /**
     * 获取动态用户列表
     *
     * @return
     */
    @GetMapping("/users/getDynamicExpertList")
    List<ExpertDynamicDto> getDynamicExpertList();

    /**
     * 根据用户ID获取社区用户详细信息
     *
     * @param userId
     * @return
     */
    @GetMapping("/users/getExpertInfoByUserId")
    ExpertInfoDto getExpertInfoByUserId(@RequestParam("userId") Integer userId);

    @GetMapping("/users/isAttention")
    Integer isAttention(@RequestParam("userId") Integer userId,
                        @RequestParam("byUserId") Integer byUserId);

    @GetMapping("/users/getDefaultAddress")
    DefaultAddressDto getDefaultAddress(@RequestParam("userId") Integer userId);

    @GetMapping("/users/getAddressByUserIdOrId")
    DefaultAddressDto getAddressByUserIdOrId(@RequestParam(value = "userId",required = false) Integer userId,
                                             @RequestParam(value = "addressId",required = false) Integer addressId);

    @GetMapping("/users/getOneAddress")
    DefaultAddressDto getOneAddress(@RequestParam(value = "userId",required = false) Integer userId,
                                    @RequestParam(value = "addressId",required = false) Integer addressId);

    @GetMapping("/users/addPraise")
    void addPraise(@RequestParam("userId") Integer userId);

    @GetMapping("/users/subPraise")
    void subPraise(@RequestParam("userId") Integer userId);

    /**
     * 添加积分
     */
    @GetMapping("/users/h5AddScore")
    Integer h5AddScore(@RequestParam("score") Integer score,
                     @RequestParam("tel") String tel);

    /**
     * 添加积分
     */
    @GetMapping("/users/addScore")
    Integer addScore(@RequestParam("score") Integer score,
                     @RequestParam("userId") Integer userId,
                     @RequestParam("type") String type);

    @GetMapping("/users/subScore")
    Integer subScore(@RequestParam("score") Integer score,
                     @RequestParam("userId") Integer userId,
                     @RequestParam("type") String type);

//    @GetMapping("/users/addBalance")
//    Integer addBalance(@RequestParam("balance") BigDecimal balance,
//                       @RequestParam("userId") Integer userId,
//                       @RequestParam("type") String type);

    @GetMapping("/account/addBalance")
    Integer addBalance(@RequestParam("balance") BigDecimal balance,
                       @RequestParam("userId") Integer userId,
                       @RequestParam("type") String type);

//    @GetMapping("/users/subBalance")
////    Integer subBalance(@RequestParam("balance") BigDecimal balance,
////                       @RequestParam("userId") Integer userId,
////                       @RequestParam("type") String type);

    @GetMapping("/account/subBalance")
    Integer subBalance(@RequestParam("balance") BigDecimal balance,
                       @RequestParam("userId") Integer userId,
                       @RequestParam("type") String type);

    @GetMapping("/users/getUsersExpertId")
    UsersExpertDto getUsersExpertId(@RequestParam("expertId") Integer expertId);

    @GetMapping("/users/isCollect")
    Integer isCollect(@RequestParam("productId") Integer productId,
                      @RequestParam("userId") Integer userId);

    @GetMapping("/users/h5GetUserIdByTel")
    Integer h5GetUserIdByTel(@RequestParam("tel") String tel,
                             @RequestParam(value = "channel",required = false) String channel,
                             @RequestParam("token") String token);

    @GetMapping("/login/saveOpenId")
    void saveOpenId(@RequestParam("userId") Integer userId,
                   @RequestParam("openid") String openid);

    @PostMapping("/users/getUsersActive")
    Integer getUserActive(@RequestBody UsersActiveRequest usersActiveRequest);

    @PostMapping("/users/insertUserActive")
    void insertUserActive(@RequestBody UsersActiveRequest usersActiveRequest);

    @GetMapping("/checkNewUser")
    Boolean checkNewUser (@RequestParam String tel);

    @PostMapping("/userScore/add")
    String addScore(@RequestBody AddUserScoreRequest addUserScoreRequest);

    /**
     * 获取用户可抵扣余额
     *
     */
    @GetMapping("/balance/getMoney")
    BigDecimal getMoney(@RequestParam("userId") Integer userId);

    /**
     * 扣除抵扣金额 退货回滚金额
     */
    @PostMapping("/account/update")
    void updateMoney(@RequestBody UserBalanceDto userBalanceDto);

    /**
     * 查询虚拟用户头像
     * @return
     */
    @GetMapping("/users/zombie/list")
    List<String> queryZombieList();

    /**
     * 获取我的钱包信息
     * @return
     */
    @GetMapping("/users/walletRpc")
    MyWalletResponse getMyWalletRpc(@RequestParam("userId") Integer userId);

    @GetMapping("/users/getMyWalletRpcAndType")
    MyWalletResponse getMyWalletRpcAndType(@RequestParam("userId") Integer userId, @RequestParam("type") Integer type);

    @GetMapping("/users/getMyWalletRpcAndIncrease")
    MyIncomeDataResponse getMyWalletRpcAndIncrease(@RequestParam("userId") Integer userId);

    @GetMapping("/users/searchUserByNickName")
    List<UsersDto> searchUserByNickName(@RequestParam("pageNum") Integer pageNum,
                                               @RequestParam("pageSize") Integer pageSize,
                                               @RequestParam("nickName") String nickName);

    @GetMapping("/account/incomeItem")
    List<DynamicIncomeDto> queryUsersIncomeItemByUserIdAndTypeAndSource(@RequestParam("userId") Integer userId,
                                                                        @RequestParam("type") String type,
                                                                        @RequestParam("source") String source,
                                                                        @RequestParam("timeType") Integer timeType);

    @GetMapping("/users/queryUsersByOpenId")
    List<UsersRpc> queryUsersByOpenId(@RequestParam("openId") String openId);

    @GetMapping("/users/queryUsersByUid")
    UsersRpc queryUsersByUid(@RequestParam("uid") String uid);

    @GetMapping("/users/queryUsersByTel")
    UsersRpc queryUsersTel(@RequestParam("tel") String tel);

    /**
     * 获取手机号获取用户最新的token缓存信息
     */
    @PostMapping("/users/getTokenUser")
    CommonResult<List<UsersResponse>> getTokenUser(@RequestBody TokenUsersRequest request);

    @PostMapping("/users/updateTokenUser")
    void updateTokenUser(@RequestBody TokenUsersRequest request);
}
